<template>
  <div class="AddressMaintainModal">
    <a-drawer
      title="授权系统"
      placement="left"
      :maskClosable="true"
      :closable="true"
      :width="1200"
      :visible="visibleModal"
      :after-visible-change="afterVisibleChange"
      @close="onCloses">
      <a-row :gutter="10">
        <!-- 左侧 -->
        <a-col :md="leftColMd" :sm="24" style="margin-bottom: 20px">
          <a-card :bordered="false">
            <!-- 人员信息 -->
            <div>
              <div style="padding-bottom:18px">
                <span style="font-weight:800;font-size:18px">用户名称: </span><span>{{ this.recordData.USERNAME }}</span> &nbsp;&nbsp;
                <span style="font-weight:800;font-size:18px">所属机构: </span><span>{{ this.recordData.REALNAME }}</span>
              </div>
              <div style="width:100%;height:1px;border: 1px solid #ddd;"></div>
            </div>
            <!-- 清空 -->
              <div class="ant-alert ant-alert-info" style="margin-top: 10px;">
                <i class="anticon anticon-info-circle ant-alert-icon">
                </i> 已拥有 <a><b>{{ selectedRowKeysLeft.length }}</b></a>个系统
                <a style="margin-left: 24px" @click="onClearSelected1">清空</a>
              </div>
              <!-- 左侧表格 -->
              <div style="margin-top: 15px">
                <a-table
                  style="height:500px"
                  ref="table"
                  size="middle"
                  bordered
                  rowKey="SYSCODE"
                  :columns="columns"
                  :dataSource="dataSource"
                  :pagination="ipagination"
                  :loading="loading"
                  :rowSelection="{selectedRowKeys: selectedRowKeysLeft, onChange: onChangeSystem}"
                  @change="handleTableChange">
                    <span slot="action" slot-scope="text,record,index">
                      <a @click="handleOpen(record,index)">关联用户</a>
                    </span>
                </a-table>
              </div>

          </a-card>
        </a-col>
        <!-- 右侧 -->
        <a-col :md="rightColMd" :sm="24" v-if="this.rightcolval == 1">
          <a-card :bordered="false">
            <div style="text-align: right;">
              <a-icon type="close-circle" @click="hideUserList" />
            </div>
            <!-- 操作按钮区域 -->
            <div class="table-operator" :md="24" :sm="24" style="margin: -25px 0px 10px 2px">
              <a-button @click="handleAddUserRole" type="primary" icon="plus" style="margin-top: 16px">添加已有用户</a-button>
              <a-button type="primary" @click="submitInfo">提交信息</a-button>
              <!-- 删除按钮 -->
              <!-- <a-dropdown v-if="selectedRowKeysRight.length > 0">
                <a-menu slot="overlay">
                  <a-menu-item key="1" @click="deleteUser">
                    <a-icon type="delete"/>
                    删除
                  </a-menu-item>
                </a-menu>
                <a-button style="margin-left: 8px">操作
                  <a-icon type="down"/>
                </a-button>
              </a-dropdown> -->
            </div>
            <!-- table区域-begin -->
            <div>
              <!-- 清空 -->
              <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
                <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{
                selectedRowKeysRight.length }}</a>项
                <a style="margin-left: 24px" @click="onClearSelected2">清空</a>
              </div>
              <!--  :dataSource="dataSource2" -->
              <a-table
                style="height:500px"
                ref="table2"
                bordered
                size="middle"
                rowKey="uuid"
                :columns="columns2"
                :dataSource="dataSorde"
                :pagination="ipagination1"
                :loading="loading2"
                :rowSelection="{selectedRowKeys: selectedRowKeysRight, onChange: onSelectChange2}"
                @change="handleTableChange2">
              <span slot="action" slot-scope="record,text,index">
                  <a-switch :checked="text.STATUS === '00' ? true : false" @change="switchButton(text,index)" checked-children="启用" un-checked-children="停用"/>
              </span>
              </a-table>
            </div>

          </a-card>
        </a-col>
        <!-- 添加用户 -->
        <a-modal :width="1000" v-model="visible" title="选择用户" @ok="handleOk"
              :okButtonProps="{
                props: { disabled: okButtonDisabled },
              }"
              @cancel="handleClose">
          <a-table
              ref="table"
              bordered
              rowKey="index"
              :columns ="columns3"
              :dataSource="allUser"
              :pagination="ipagination2"
              :rowSelection="{selectedRowKeys: selectedRowKeysModal, onChange: onSelectChange}"
              @change="handleTableChange1"
          >
              <span slot="action" slot-scope="text, record">
                <a>
                  <a-select  style="width: 230px;" placeholder="请选择部门" label-in-value v-model="record.DEFAULTDEPTCODE">
                    <a-select-option :value="item.DEPTCODE" @click="handleChange(item,record)" v-for="item in department" :key="item.DEPTID">
                        {{item.DEPTNAME}}
                    </a-select-option>
                  </a-select>
                </a>
              </span>
          </a-table>
        </a-modal>
      </a-row>
    </a-drawer>
  </div>

</template>

<script>
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import { deleteAction, postAction, getAction } from '@/api/manage'
  import { filterObj, randomString } from '@/utils/util'
  import moment from 'moment'
  import store from '@/store'

  export default {
    name: 'RoleUserList',
    mixins: [JeecgListMixin],
    components: {

    },
    data(){
      return{
        visibleModal:false,
        tableName:"IDM_BASE_SYSINFO", //所有系统
        tableNameLeft:'IDM_PUBLIC.IDM_GET_USERPERMISSON',  //获取用户权限回显
        table:'IDM_BASE_SYSUSER',  //停用启用
        procedure:'IDM_PUBLIC.IDM_UPD_USERPERMISSION', // 提交权限
        tableName1:'IDM_BASE_SYSUSER',//某系统下所有用户
        sectionList:'IDM_BASE_SYSDEPTINFO',// 某系统下所有部门
        model1: {},
        model2: {},
        currentRoleId: '',
        queryParam1: {},
        queryParam2: {},
        dataSource1: [], //  右侧表格数据
        dataSource2: [],
        // 分页数据
        ipagination: {
          current: 1,
          pageSize: 10,
          pageSizeOptions: ['10', '20', '30'],
          showTotal: (total, range) => {
            return range[0] + '-' + range[1] + ' 共' + total + '条'
          },
          showQuickJumper: true,
          showSizeChanger: true,
          total: 0
        },
        ipagination1: {
          current: 1,
          pageSize: 10,
          pageSizeOptions: ['10', '20', '30'],
          showTotal: (total, range) => {
            return range[0] + '-' + range[1] + ' 共' + total + '条'
          },
          showQuickJumper: true,
          showSizeChanger: true,
          total: 0
        },
        ipagination2: {
          current: 1,
          pageSize: 10,
          pageSizeOptions: ['10', '20', '30'],
          showTotal: (total, range) => {
            return range[0] + '-' + range[1] + ' 共' + total + '条'
          },
          showQuickJumper: true,
          showSizeChanger: true,
          total: 0
        },
        isorter1: {
          column: 'createTime',
          order: 'desc'
        },
        isorter2: {
          column: 'createTime',
          order: 'desc'
        },
        filters1: {},
        filters2: {},
        loading1: false,
        loading2: false,
        // 选中的key
        selectedRowKeysLeft: [],
        selectedRowKeysRight: [],
        selectedRowKeysModal: [],
        // 选中的值
        selectionRowsLeft: [],
        selectionRowsRight: [],
        selectionRowsModal: [],
        test:{},
        rightcolval:0,
        // 左侧表格
        columns:
          [
            {
              title: '系统代码',
              align: 'center',
              dataIndex: 'SYSCODE',
              key:1,
            },
            {
              title: '系统名称',
              align: 'center',
              dataIndex: 'SYSNAME',
              key:2,
            },
            {
              title: '系统类型',
              dataIndex: 'SYSTYPE',
              align:"center",
              key:3,
            },
            {
              title: '网络类型',
              align: 'center',
              dataIndex: 'NETTYPE_dictText',
              key:4,
            },
            {
              title: '操作',
              dataIndex: 'action',
              align: 'center',
              scopedSlots: { customRender: 'action' }
            },
          ],
        // 右侧表格
        columns2: [
           {
          title: '用户账号',
          align: 'center',
          dataIndex: 'USERID',
          width: 120
          },
          {
            title: '用户名称',
            align: 'center',
            width: 100,
            dataIndex: 'USERNAME'
          },
          {
            title: '所属系统',
            align: 'center',
            width: 80,
            dataIndex: 'SYSNAME'
          },
          {
            title:'默认部门',
            align:'center',
            width:100,
            dataIndex: 'DEFAULTDEPTNAME'
          },
          {
            title: '操作',
            dataIndex: 'action',
            scopedSlots: { customRender: 'action' },
            align: 'center',
            width: 120
          }
        ],
        // 模态框表格
        columns3:[
           {
          title: '用户账号',
          align:"center",
          dataIndex: 'USERID',
          // fixed:'left',
          },
          {
            title: '用户名称',
            align:"center",
            dataIndex: 'USERNAME',
          },
          {
            title: '所属系统',
            align:"center",
            dataIndex: 'SYSNAME'
          },
          {
            title: '部门',
            align:"center",
            dataIndex: 'DEPTNAME',
            key: 'action',
            scopedSlots: { customRender: 'action' },
          width:200
          }
        ],

        url: {
          list:'/common/select', //获取左边表格数据(所有系统)
          systemList:'/getPermission', //获取左侧表格已有系统
          procedureLeft:"/crud/procedure", //获取右边表格数据(用户权限)
          switch:'/crud/update', //停用启用
          submit:'/crud/procedure', //提交信息
          select:'/common/select', // 所有用户
          division:'/common/select' // 获取所有部门

        },
        // 点击授权的时候传递过来的参数
        usercode:this.recordData.USERNAME,
        idmuserid:this.recordData.ID,
        idmusercode:this.recordData.USERNAME,
        idmusername:this.recordData.USERNAME,
        idmdeptcode:this.recordData.ORG_CODE,
        // 表格数据
        dataSource:[],
        procedureLeft:[], //获取右边表格数据(用户权限)
        existingSystem:[], //用户的所有的系统
        selectedTableRow:[],   //用来接收selectedRowKeys的数组
        // 用户选中的数据
        userSelect:[],
        // 所授权系统的信息
        syscode:[],
        sysname:[],
        // userinfo
        userinfo:[],
        // 右侧数据
        dataSorde:[],
        // 所有用户
        allUser:[],
        // 对话框
        visible: false,
        // userSelectInfo:[],
        status:true,
        // 所有部门
        department:[],
        // 获取所有部门入参
        sectionValue:[],
        selectedDeptInfo: [],
        okButtonDisabled: false,
        // 左侧已有系统
        alreadySystem:[],
        // 复选
        selectedSystem:[],
        fatherData:{}
     }
    },
    props:{
      recordData:{
        type:Object,
        required:true
      }
    },
    // watch:{
    //   recordData(value){
    //     this.fatherData = value
    //     this.usercode = value.USERNAME
    //     this.idmuserid = value.ID
    //     this.idmusercode = value.USERNAME
    //     this.idmusername = value.USERNAME
    //     this.idmdeptcode = value.ORG_CODE
    //   }
    // },
    computed: {
      importExcelUrl: function() {
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
      },
      leftColMd() {
        return this.selectedRowKeysLeft.length === 0 ? 24 : 12
      },
      rightColMd() {
        return this.selectedRowKeysLeft.length === 0 ? 0 : 12
      },
    },
    methods:{
      onSelectChange2(selectedRowKeys, selectionRows) {
        console.log("selectionRows",selectionRows)
        // this.userSelectInfo = selectionRows
        this.userinfo = []
        selectionRows.forEach((item,index) =>{
          let userItem = {
            usercode: item.USERCODE,
            username: item.USERNAME,
            defaultdeptcode: item.DEFAULTDEPTCODE,
            status: item.STATUS
          }
          this.userinfo.push(userItem)
        })

        this.selectedRowKeysRight = selectedRowKeys
        this.selectionRowsRight = selectionRows
      },
      // 右侧清空
      onClearSelected2() {
        this.selectedRowKeysRight = []
        this.selectionRowsRight = []
      },
      // 左侧清空
      onClearSelected1() {
        this.selectedRowKeysLeft = []
        this.selectionRowsLeft = []
      },
     onSelectChange (selectedRowKeys, selectionRows) {
        this.selectedRowKeysModal = selectedRowKeys
        this.selectionRowsModal = selectionRows
     },
      // 获取左边表格数据(所有系统)
      async getList(){
        const reqBody = {
          table: this.tableName,
          columnMap: {
              ID:null,
              SYSCODE:null,
              SYSNAME:null,
              SYSTYPE:{dictCode: "appl-type"},
              NETTYPE:{dictCode: "appl-network-type"},
              CREATEDATE:{dateTimeType: "date"},
              CREATEUSER:null,
              MODIFYDATE:{dateTimeType: "datetime"},
              MODIFYUSER:null,
              MARK:null,
              ICON:null,
              API:null,
              APITYPE:{dictCode: "appl-apitype"}
            },
            orderBy: {CREATEDATE: -1, MODIFYDATE: -1},
            pageInfo: { pageSize: this.ipagination.pageSize, pageNo: this.ipagination.current },
        };
        const res = await postAction(this.url.list, reqBody)
        if(res.code === 2000){
          this.dataSource = res.data.result
        console.log("dataSource",this.dataSource)
        }
      },
      // 获取左侧表格已有系统
      async systemList(){
        let usercode = store.getters.userInfo.username
        const reqBody ={
          usercode:usercode,
          systype:null
        }
        const res = await postAction(this.url.systemList,reqBody)
        const systemList = res.data || {}
        this.alreadySystem = systemList.resultList
        // 左侧默认选中
        this.selectedRowKeysLeft = systemList.resultList.map(item => item.SYSCODE)
        // 选中多少项
        this.selectedRowKeysLeft = [...new Set(this.selectedRowKeysLeft)]
        if (this.selectedRowKeysLeft.length) this.rightcolval = 1
      },
      // 获取右边表格数据(用户权限)
      async userPermisson(){
        const reqBody = {
          procedure: this.tableNameLeft,
          inArgs:[{ usercode:this.recordData.USERNAME}],
          ifReturnCursor:true
          }
          console.log("右侧数据reqBody",reqBody)
          const res = await postAction(this.url.procedureLeft,reqBody)
            if(res.code === 2000){
            // 用户拥有的系统
             this.procedureLeft = res.data.resultList
            //  系统下所有的用户
             this.dataSource1 = res.data.resultList
             console.log("右侧数据",this.dataSource1)
          }
      },
      // 复选
      onChangeSystem(selectedRowKeys, selectionRows){
        this.rightcolval = 1
        this.selectionRowsLeft = selectionRows
        this.selectedRowKeysLeft = selectedRowKeys.reduce((arr, item) => {
          if (!arr.includes(item)) {
            arr.push(item)
          }
          return arr
        }, [])
        // // 清除右边已选中数据
        // this.selectedRowKeysRight = []
        // this.selectionRowsRight = []
      },
      // 提交所有信息
      async submitInfo(){
        if (!this.selectedRowKeysLeft.length || !this.selectedRowKeysRight.length) {
          return this.$message.error('请先选择提交的信息!')
        }
        // 当前登录的用户
        let usercode = store.getters.userInfo.username
        // 左侧数据
        let systemInfo = this.selectionRowsLeft.map(item => {
          // 左侧表格
          let currentInfo = {
            syscode: item.SYSCODE,
            sysname: item.SYSNAME,
            userinfo: []
          }
          // 右侧用户信息
          let userInfo = this.selectionRowsRight.map(user => {
            return {
              username: user.USERNAME,
              usercode: user.USERCODE,
              defaultdeptcode: user.DEFAULTDEPTCODE.key || user.DEFAULTDEPTCODE,
              status: user.STATUS,
            }
          })
          currentInfo.userinfo = userInfo
          return currentInfo
        })

        const reqBody = {
           procedure: this.procedure,
            inArgs: [
              {
                optuser: usercode,
                idmuserinfo: {
                  idmuserid:this.recordData.ID,
                  idmusercode:this.recordData.USERNAME,
                  idmusername:this.recordData.USERNAME,
                  idmdeptcode:this.recordData.ORG_CODE,
                },
                sysinfo: systemInfo
              }
            ],
            ifReturnCursor: true
        }
        console.log("右侧用户信息",reqBody)
        const res = await postAction(this.url.submit,reqBody)
        if(res.code == 2000){
          this.$message.info('提交成功');
          this.userPermisson()
        }else{
          this.$message.error('提交失败');
        }
      },
      // 左侧表格单选按钮触发  selectedRowKeys:选中的第几项 selectionRows:选中的每一项数据
      onSelectChange1(selectedRowKeys, selectionRows) {
        this.selectedTableRow = selectedRowKeys
        // 右侧表格是否显示 0/1
        this.rightcolval = 1
        // 选中状态
        this.selectedRowKeysLeft = selectedRowKeys
        this.selectionRowsLeft = selectionRows
        // 当前行数据
        this.model1 = Object.assign({}, selectionRows[0])
        // 当前选中列的id
        this.currentRoleId = selectedRowKeys[0]
        // this.loadData2()
        // 用户选中的数据
        this.select =  selectionRows
      },
      onClearSelected() {
      },

      getQueryParams2() {
        //获取查询条件
        let sqp = {}
        if (this.superQueryParams2) {
          sqp['superQueryParams'] = encodeURI(this.superQueryParams2)
        }
        var param = Object.assign(sqp, this.queryParam2, this.isorter2, this.filters2)
        param.field = this.getQueryField2()
        param.pageNo = this.ipagination2.current
        param.pageSize = this.ipagination2.pageSize
        return filterObj(param)
      },
      getQueryField2() {
        //TODO 字段权限控制
        var str = 'id,'
        this.columns2.forEach(function(value) {
          str += ',' + value.dataIndex
        })
        return str
      },
      handleTag(selectedRowKeys, selectionRows){
      },

      modalFormOk2() {
        // 新增/修改 成功时，重载列表
        // this.loadData2()
      },
      handleDelete1: function(id) {
        this.handleDelete(id)
        this.dataSource2 = []
        this.currentRoleId = ''
      },
      handleDelete2: function(id) {
        if (!this.url.delete2) {
          this.$message.error('请设置url.delete2属性!')
          return
        }
        var that = this
        deleteAction(that.url.delete2, { roleId: this.currentRoleId, userId: id }).then((res) => {
          if (res.success) {
            that.$message.success(res.message)
            that.loadData2()
          } else {
            that.$message.warning(res.message)
          }
        })
      },
      // 批量删除
      batchDel2(){
        this.visible = true
      },
      // 用户选择的部门
      handleChange(value,record){
        let key = value.DEPTCODE;
        let label = value.DEPTNAME;

        const isRepeatId = this.handleIsEqual(key, record)
        if (isRepeatId) {
          this.$message.error(label + '部门已被选择,请重新选择其他部门!')
          this.okButtonDisabled = true
        } else {
          this.okButtonDisabled = false
          this.$set(record,"DEFAULTDEPTCODE",key)
          this.$set(record,"DEFAULTDEPTNAME",label)
        }
      },
      // 确定按钮
      handleOk() {
        // 用户选中的数据和长度
        if (this.selectionRowsModal && this.selectionRowsModal.length) {
          const noDeptName = this.selectionRowsModal.find(item => !item.DEFAULTDEPTCODE)
          if (noDeptName) {
            return this.$message.error('请选择部门!')
          }
          const isRepeat = this.selectionRowsModal.find(modalItem => {
            const deptCode = modalItem.DEFAULTDEPTCODE && modalItem.DEFAULTDEPTCODE.key
            return this.handleIsEqual(deptCode, modalItem)
          })

          if (isRepeat) {
            const deptName = (isRepeat.DEFAULTDEPTCODE && isRepeat.DEFAULTDEPTCODE.label) || ''
            return this.$message.error(deptName + '部门已被选择,请重新选择其他部门!')
          }

          this.dataSorde = this.dataSorde.concat(JSON.parse(JSON.stringify(this.selectionRowsModal)))
          this.selectionRowsRight = JSON.parse(JSON.stringify(this.dataSorde))
          // 默认选中
          this.selectedRowKeysRight = this.dataSorde.map(item => item.uuid)
          this.handleClose()
        } else {
          this.$message.error('请选择添加的用户!')
        }
      },
      // 判断是否有相同用户选中相同的部门
      handleIsEqual(key, record) {
        return this.dataSorde.find(item => {
          let isEqualKey = (item.DEFAULTDEPTCODE && item.DEFAULTDEPTCODE.key === key) || item.DEFAULTDEPTCODE === key
          let isEqualUserCode = item.USERCODE === record.USERCODE
          if (isEqualKey && isEqualUserCode) {
            return item
          }
        })
      },
      // 弹窗关闭
      handleClose() {
        this.visible = false
        this.okButtonDisabled = false
        this.selectedRowKeysModal = []
        this.selectionRowsModal = []
      },

      handleAddUserRole() {
        if (this.currentRoleId == '') {
          this.$message.error('请选择一个角色!')
        } else {
           this.allUser = this.allUser.map(item => {
             const { DEFAULTDEPTCODE, DEFAULTDEPTNAME, ...args} = item
             return args
           });
           this.visible = true;
        }
        // this.getlistModal()
      },
      // 点击关联用户触发
      async handleOpen(record,index) {
        // 用户选中的系统编码
        this.worth = record.SYSCODE
        this.dataSorde = this.dataSource1.filter(item => {
          item.uuid = randomString(8)
          return item.SYSCODE === record.SYSCODE
        })
        this.selectionRowsRight = JSON.parse(JSON.stringify(this.dataSorde))
        this.$nextTick(() => {
          this.selectedRowKeysRight = this.dataSorde.map(item => item.uuid)
        })
        this.selectionRowsLeft = [record]
        // 右侧表格是否显示 0/1
        this.rightcolval = 1
        // 左侧表格选择项数组
        if (!this.selectedRowKeysLeft.includes(record.SYSCODE)) {
          this.selectedRowKeysLeft.push(record.SYSCODE)
        }
        // 分解数组
        this.model1 = Object.assign({}, record)
        // 当前选中列的id
        this.currentRoleId = index[0]
        // 清空数组
        // this.onClearSelected2()
        // 点击的时候加载右侧的数据
        // 点击关联用户获取所有用户
        const reqBody={
              table:this.tableName1,
              columnMap:{
                  ID: null,
                  SYSCODE: null,
                  SYSNAME: null,
                  CREATEDATE: {"dateTimeType": "datetime"},
                  CREATEUSER: null,
                  MODIFYDATE: {"dateTimeType": "datetime"},
                  MODIFYUSER: null,
                  MARK: null,
                  USERID: null,
                  USERCODE: null,
                  USERNAME: null,
                  USERTYPE: null,
                  STATUS: null,
                  PASSWORD: null,
                  PWDSALT: null,
                  SYSID: null,
                  MOBILE: null,
                  WECHATOPENID: null,
                  PWDTYPE: null,
                  FIRSTLOGIN: null,
                  CLEARTEXT: null
              },
              where: [
                {or: [{
                  column: "SYSCODE",
                  operator: "eq",
                  value: this.worth
                }]}
              ],
              orderBy: {CREATEDATE: -1, MODIFYDATE: -1},
              pageInfo: { pageSize: this.ipagination.pageSize, pageNo: this.ipagination.current}
        }
        const res = await postAction(this.url.select,reqBody)
        console.log("res",res)
        if(res.code === 2000){
          this.allUser = res.data && res.data.result
          this.allUser = this.allUser.map(item => {
            item.uuid = randomString(8)
            return item
          })
        }
        // 点击关联获取所有部门
        const requestBody = {
          "table":this.sectionList,
          "columnMap": {
                "ID": null,
                "SYSCODE": null,
                "SYSNAME": null,
                "DEPTID": null,
                "DEPTCODE": null,
                "DEPTNAME": null,
                "CREATEDATE": {"timeFormat": "datetime"},
                "CREATEUSER": null,
                "MODIFYDATE": {"timeFormat": "datetime"},
                "MODIFYUSER": null,
                "MARK": null,
                "OWNERCODE": null,
                "OWNERNAME": null
            },
              "where": [
            {"or": [{
              "column": "syscode",
              "operator": "eq",
              "value": record.SYSCODE
            }]}
          ],
          "pageInfo": {pageSize: this.ipagination.pageSize, pageNo: this.ipagination.current }
        }
        postAction(this.url.division,requestBody).then((res) => {
          this.department = res.data.result
        }).catch((err)=>{
          console.log(err)
        })
      this.userPermisson()
      },
      //分页
      handleTableChange2(pagination, filters, sorter) {
        this.ipagination1.current = pagination.current
        this.ipagination1.pageSize = pagination.pageSize
      },
      handleTableChange1(pagination, filters, sorter) {
        this.ipagination2.current = pagination.current
        this.ipagination2.pageSize = pagination.pageSize
      },
      handleTableChange(pagination, filters, sorter) {
        this.ipagination.current = pagination.current
        this.ipagination.pageSize = pagination.pageSize
      },
      hideUserList(){
        this.selectedRowKeysLeft = []
      },
      handlePerssion(roleId){
        this.$refs.modalUserRole.show(roleId);
      },
      // 停用启用
      async switchButton(text, index){
        console.log("text",text)
        let value = text.ID
        let status = text.STATUS === '00' ? '10' : '00'

        const reqBody = {
          table:this.table,
          setClause:{status:status},
          where: [
              {"or": [{ "column": "id", "operator": "eq", "value": value}]}
            ]
        }

        const res = await postAction(this.url.switch,reqBody)
        if(res.code === 2000){
          this.$message.success('操作成功')
          this.$set(this.dataSorde[index], 'STATUS', status)
          this.userPermisson()
        }
      },

      onCloses(){
        this.visibleModal = false
      },
      afterVisibleChange(val){

      },
      openModal(){
        this.visibleModal = true
      }
    },
    mounted(){
      this.getList()
      // this.userPermisson()
      this.systemList()
    },
    beforeDestroy(){
     this.selectedRowKeysLeft =[]
    },
  }
</script>

<style lang="less" scoped>
  /** Button按钮间距 */
  .ant-btn {
    margin-left: 8px,
  }
</style>
